package com.bjpowernode.other.lock;

/**
 * 死锁
 */
public class DeadLock {
    private static Object obj1 = new Object();
    private static Object obj2 = new Object();

    public static void main(String[] args) {
        Runnable r1 = ()->{
            synchronized (obj1) {
                System.out.println("Lock01");
                synchronized (obj2) {
                    System.out.println("Lock02");
                }
            }
        };

        Runnable r2 = ()->{
            synchronized (obj2) {
                System.out.println("Lock03");
                synchronized (obj1) {
                    System.out.println("Lock04");
                }
            }
        };

        new Thread(r1).start();
        new Thread(r2).start();

    }

}
